package com.atguigu.tingshu.album.client;

import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.annotation.cache.Cache;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 分类数据内部调用接口
 * @author Haoran Sun
 * @since 2024/08/21
 */

@RestController
@RequestMapping("client/album/category")
public class BaseCategoryClientController {

    @Resource
    private BaseCategoryService baseCategoryService;

    /**
     * 获取分类数据
     * @param category3Id 三级分类id
     * @return  分类数据
     */
    @GetMapping("/getBaseCategoryView/{category3Id}")
    @Cache(value = "cache:album:getBaseCategoryView")
    public BaseCategoryView getCategoryView(@PathVariable("category3Id") Long category3Id) {
        return baseCategoryService.getCategoryView(category3Id);
    }

    /**
     * 根据一级分类idTOP7的三级分类
     * @param category1Id 一级分类id
     * @return 三级分类
     */
    @GetMapping("/findTopBaseCategory3/{category1Id}")
    @Cache(value = "cache:album:findTopBaseCategory3")
    public List<BaseCategory3> findTopBaseCategory3(@PathVariable("category1Id") Long category1Id){
        return baseCategoryService.findTopBaseCategory3(category1Id);
    }



}
